package com.dtream.nacos.openfeig;

import com.dtream.nacos.entity.ExampleEntity;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.validation.Valid;
import java.util.List;

@FeignClient(name = "depositchain-service-test", fallback = ExampleHystrix.class)
public interface ExampleClient {

    @RequestMapping(value = "/v1/example/list", method = RequestMethod.GET)
    public ResponseEntity<List<ExampleEntity>> getClientUsersList();

    @RequestMapping(value = "/v1/example/{id}", method = RequestMethod.GET)
    public ResponseEntity<ExampleEntity> getClientUsers(@PathVariable String id);

    /*
    创建用户
     */
    @RequestMapping(value = "/v1/example/create", method = RequestMethod.POST)
    public ResponseEntity<ExampleEntity> createUser(@RequestBody ExampleEntity users);

    /**
     * 根据id更新用户信息
     */
    @RequestMapping(value = "/v1/example/{id}", method = RequestMethod.PUT)
    public ResponseEntity<ExampleEntity> updateUser(@PathVariable("id") String id, @Valid @RequestBody ExampleEntity user);

    @RequestMapping(value = "/v1/example/{id}", method = RequestMethod.DELETE)
    public ResponseEntity<String> deleteUser(@PathVariable String id);
}
